var tree, addDevice, editDevice, queryChildren,
    addPart, editPart,
    addDynamicPoint, editDynamicPoint,
    addStaticPoint, editStaticPoint, deleteNodes, selectNodeId;

layui.use(['jquery', 'layer', 'table', 'laydate'], function () {
    var $ = layui.jquery,
        layer = layui.layer,
        table = layui.table;

    var treeCols = [
        [
            {type: 'checkbox'},
            {field: 'name', width: '20%', title: '名称', sort: true},
            {field: 'code', width: '15%', title: '编码', sort: true},
            {field: 'description', title: '描述', sort: true},
            {field: 'nodeTyppe', width: '15%', title: '类型', sort: true},
            {field: 'createTime', width: '20%', title: '创建时间', sort: true}
        ]
    ];

    queryChildren = new ListQuery(table, {
        cols: treeCols,
        element: "#tablelist",
        url: contextRoot + "system_manage/configuration_tree/doListChildren",
        page: 1,
        pageable: false,
        tableid: "tree_node_table",
        extraData: function () {
            return {parentId: selectNodeId};
        }
    });

    addDevice = new TreeAdd(layer, {
        title: "添加设备",
        url: contextRoot + "device/getAddDevice/" + $("#parentId").val(),
        width: "730px",
        height: "640px"
    }, queryChildren, tree);

    editDevice = new TreeEdit(layer,
        {
            title: "修改设备",
            url: contextRoot + "device/getEditDevice",
            width: "730px",
            height: "640px"
        }, queryChildren, tree);

    addPart = new TreeAdd(layer, {
        title: "添加部件",
        url: contextRoot + "part/getAddPart/" + $("#parentId").val(),
        width: "730px",
        height: "640px"
    }, queryChildren, tree);

    editPart = new TreeEdit(layer, {
        title: "修改部件",
        url: contextRoot + "part/getEditPart",
        width: "730px",
        height: "640px"
    }, queryChildren, tree);


    addDynamicPoint = new TreeAdd(layer, {
        title: "添加动态测点",
        url: contextRoot + "dynamicPoint/getAddDynamicPoint/" + $("#parentId").val(),
        width: "750px",
        height: "640px"
    }, queryChildren, tree, true);

    editDynamicPoint = new TreeEdit(layer,
        {
            title: "修改动态测点",
            url: contextRoot + "dynamicPoint/getEditDynamicPoint",
            width: "750px",
            height: "640px"
        }, queryChildren, tree, true);


    addStaticPoint = new TreeAdd(layer, {
        title: "添加静态测点",
        url: contextRoot + "staticPoint/getAddStaticPoint/" + $("#parentId").val(),
        width: "750px",
        height: "640px"
    }, queryChildren, tree, true);

    editStaticPoint = new TreeEdit(layer,
        {
            title: "修改静态测点",
            url: contextRoot + "staticPoint/getEditStaticPoint",
            width: "750px",
            height: "640px"
        }, queryChildren, tree, true);

    deleteNodes = new TreeDelete(layer, queryChildren, tree, {
        url: contextRoot + "system_manage/configuration_tree/doDeleteChildren",
    });
});